package com.example.carapi.service.implement;

import com.example.carapi.bean.CarModel;
import com.example.carapi.mapper.CarModelMapper;
import com.example.carapi.service.CarModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarModelServiceImplement implements CarModelService {
    @Autowired
    private CarModelMapper carModelMapper;

    @Override
    public CarModel getCarModelById(Long id) {
        return carModelMapper.getOne(id);
    }

    @Override
    public List<CarModel> getCarModels() {
        return carModelMapper.getAll();
    }

    @Override
    public void addCarModel(CarModel carModel) {
        carModelMapper.insert(carModel);
    }

    @Override
    public void updateCarModel(CarModel carModel) {
        carModelMapper.update(carModel);
    }

    @Override
    public void deleteCarModelById(Long id) {
        carModelMapper.delete(id);
    }
}
